
<%@ page import="coe.pumbaa.Category" %>
<% def springSecurityService = application.getAttribute("org.codehaus.groovy.grails.APPLICATION_CONTEXT").getBean("springSecurityService") %>
<!doctype html>
<html>
  <head>
    <meta name="layout" content="PumbaaLayout">
  <g:set var="entityName" value="${message(code: 'category.label', default: 'Category')}" />
  <title>Category</title>
</head>
<body>
  <section id="main" class="column">
    <pumbaa:alert />
    <article class="module width_full">
      <header><h3>Category</h3></header>
      <table class="tablesorter" cellspacing="0">
        <thead>
          <tr>
            <th>Title</th>
            <th>Description</th>
         <g:if test="${(springSecurityService.isLoggedIn())&&(springSecurityService?.currentUser?.role.level <= 1)}">
          <th style="width: 10%;">Actions</th> 
        </g:if>
        </tr>
        </thead>
        <tbody>
        <g:each in="${categoryInstanceList}" var="categoryInstance">
          <tr>
            <td><g:link controller="post" action="list" id="${categoryInstance.id}">${fieldValue(bean: categoryInstance, field: "title")}</g:link></td>
          <td>${fieldValue(bean: categoryInstance, field: "description")}</td>
          <g:if test="${(springSecurityService.isLoggedIn())&&(springSecurityService?.currentUser?.role.level <= 1)}">
            <td>
            <g:link action="edit" id="${categoryInstance.id}"><input type="image" src="${resource(dir: 'images', file: 'icn_edit.png')}" title="Edit"></g:link>
            <g:link action="delete" id="${categoryInstance.id}"><input type="image" src="${resource(dir: 'images', file: 'icn_trash.png')}" title="Trash" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"></g:link>
            </td>
          </g:if>
          </tr>
        </g:each>
        </tbody>
      </table>
      <footer>
        <div class="pagination">
          <h4><g:paginate total="${categoryInstanceTotal}" /></h4>
        </div>
      </footer>
    </article>
     <g:if test="${(springSecurityService.isLoggedIn())&&(springSecurityService?.currentUser?.role.level <= 1)}">
      <div class="submit_link">
        <g:link action="create"><g:actionSubmit class="alt_btn" name="createBtn" value="Create Category"/></g:link>
      </div>
    </g:if>
    <div class="spacer"></div>
  </section>
</body>
</html>
